#ifndef TILE_H_INCLUDED_75349064
#define TILE_H_INCLUDED_75349064
//-----------------------------------------------------------------------------
// Copyright (c) 2011 David Waby
// Initially created on 31/10/2011
//-----------------------------------------------------------------------------

#include "IJsonSerialisable.h"
class TileAttribute;
      
//-----------------------------------------------------------------------------
class Tile : public IJsonSerialisable
{
public:

	struct TileAttributes
	{
		enum Enum
		{
			Walkable			= 0x00000001,
			Portal				= 0x00000002,
			Chest				= 0x00000004,
		};
	};

									Tile(int const x, int const y);
	virtual							~Tile();

	void							SetAttribute(TileAttributes::Enum const i_attribute, bool const i_set);
	bool							HasAttribute(TileAttributes::Enum const i_attribute) const;
	TileAttribute *					GetAttribute() const;

	void							EnterTile();
	void							UseTile();
	void							ExitTile();

	virtual void					Serialise(Json::Value * o_root) const;
	virtual void					Deserialise(Json::Value const * i_root);

private:

	void							CreateAttribute(TileAttributes::Enum const i_attribute);
	void							DeleteAttribute(TileAttributes::Enum const i_attribute);

	Point2							m_position;
	BitFlag							m_flags;
	TileAttribute *					m_attribute;

									Tile();
									Tile(const Tile &rhs);
									Tile& operator = (const Tile &rhs);
};

//-----------------------------------------------------------------------------
#endif // TILE_H_INCLUDED_75349064
